--- title: "Scales S" created: 2025-11-28 tags: - 算法 --- # Scales S ## 题目 [Scales S](https://www.luogu.com.cn/problem/P5194) ![[image-1c6d364e.png]] ## 思路分析 一眼看过去 n中选m 求最大值 每种物品有两种选择 选或不选 两种解法——dfs、01背包dp 有点坑的地方是 dfs能60分 dp只能20分(内存、空间超限) ## 代码实现 ```cpp #include using namespace std; #define endl '\n' #define int long long using ll = long long; using ull = unsigned long long; using PII = pair; using Pll = pair; int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 }; const int inf = 0x3f3f3f3f; signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); return 0; } ``` ## 同类题型 ## 视频讲解 --- ⬅️ [[火星人|火星人]] 🏠 [[00-刷题理模型]] ➡️ [[奇迹|奇迹]]